<template>
  <el-button-group>
    <button-input
      v-for="(button, bIndex) in buttonGroups"
      :key="bIndex"
      v-bind="button"
      :button="button"
      v-on="inheritListeners(button)"
    >
    </button-input>
  </el-button-group>
</template>

<script>
import buttonInput from "./input";
export default {
  components: {
    "button-input": buttonInput,
  },
  name: "TableColumn",
  data() {
    return {};
  },
  props: {
    buttonGroups: {
      type: Array,
      required: true,
    },
  },
  created() {},
  methods: {
    // 继承转换事件
    inheritListeners(button) {
      let listeners = this.$public.inheritListeners({
        $attrs: button,
        $listeners: {},
      });

      Object.keys(listeners).forEach((event) => {
        let tempAction = listeners[event];

        listeners[event] = function () {
          tempAction.apply(null, [].concat(Array.from(arguments)));
        };
      });

      return listeners;
    },
  },
};
</script>

<style scoped>
.el-button-group:not(:first-child) {
  /* margin-left: 10px; */
}
</style>
